<template>
	<view>

		<u-navbar :is-back="back" :titleStyle="{color:color}" :title="title" :bgColor="bgColor" :border-bottom="false"
			:placeholder="true" :leftIcon="getIcon()" @leftClick="left" :safeAreaInsetTop="true" placeholder
			:fixed="fixed" :leftIconColor='leftIconColor'>
			
			<view slot="right">
				<slot name="right">

				</slot>
			</view>


		</u-navbar>

	</view>
</template>

<script>
	import style from '../uni.scss'
	export default {
		name: "baseNavbar",
		props: {
			title: {
				type: String,
				default: ''
			},
			back: {
				type: Boolean,
				default: false
			},
			bgColor: {
				type: String,
				default: style.baseColor
			},
			istwo:{
				type:Boolean,
				default:false
			},
			fixed: {
				type: Boolean,
				default: true
			},
			leftIconColor: {
				type: String,
				default: '#000'
			},
			color: {
				type: String,
				default: '#000'
			},
		},


		data() {
			return {
				length: 1
			};
		},
		mounted() {
			let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
			this.length = currentRoutes.length
			console.log("?长度》》》》》", currentRoutes.length)
		},
		methods: {
			left() {
				if (this.back) {
					if (this.length > 1&&!this.istwo) {
						uni.navigateBack({
							delta: 1
						})
					}else if(this.istwo&&this.length > 1){
						uni.navigateBack({
							delta: 2
						})
					}else{
						uni.switchTab({
							url: "/pages/index/index"
						})
					}

				}

			},
			getIcon() {
				if (this.back) {
					if (this.length > 1)
						return 'arrow-left'
					return 'home'
				}
				return ''
			}
		}

	}
</script>

<style>

</style>
